home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / gfft.lha / gfft-2.03 / source / gfft-2.03-source.lha / settings.c < prev    next >
C/C++ Source or Header  |  1996-01-02  |  33KB  |  1,497 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        settings.c
  13.  * Purpose:     set values, names, and operation types
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     31-May-1993 CPP; Created.
  16.  *              9-Aug-94 CPP (1.10); Hidden3D option
  17.  *              19-Jan-95 CPP (1.21); Topaz command
  18.  *              10-Feb-95 CPP (1.39; save settings or parameters
  19.  *              14-Feb-95 CPP (1.42); PlotCommands
  20.  */
  21.  
  22. #include <stdio.h>     /* printf */
  23. #include <string.h>    /* strtok, strlen */
  24. #include <stdlib.h>    /* strtoul */
  25. #include <errno.h>     /* errno */
  26.  
  27. #include "gfft.h"
  28.  
  29. #define DEFINE_HERE
  30. #include "settings.h"
  31. #undef DEFINE_HERE
  32.  
  33. extern Name_Info_St Gfft_Command[];  /* GFFT commands */
  34.  
  35. static char *set_ulong (char *arguments, unsigned long *longp, 
  36.                int gt_0_req, int arg_req);
  37.  
  38. static char *set_double (char *arguments, double *doublep, 
  39.                int gt_0_req, int arg_req);
  40.  
  41. static char *get_filename (char *arguments, char **filename_pp);
  42.  
  43. static char *add_calibration (char *arguments, BOOLEAN db_scale);
  44.  
  45. char *set (char *arguments)
  46. {
  47. /*
  48.  * Dummy command which invokes its arguments as a command string
  49.  */
  50.     if (arguments && arguments != NullString)
  51.     {
  52.     invoke_method (arguments, Gfft_Command);
  53.     }
  54.     return arguments;
  55. }
  56.  
  57. /*
  58.  * Functions to set various parameters
  59.  */
  60.  
  61. char *set_time_offset (char *arguments)
  62. {
  63.     char *more_arguments;
  64.     ULONG time_offset;
  65.  
  66.     TimeOffset = INVALID_SET;  /* unless this succeeds */
  67.     more_arguments = set_ulong (arguments, &time_offset, FALSE, FALSE);
  68.     if (more_arguments == NullString)
  69.     {
  70.     TimeOffset = NOT_SET;
  71.     }
  72.     else
  73.     {
  74.     Time3D = TRUE;
  75.     if (time_offset > 0 && time_offset < LONG_MAX)
  76.     {
  77.         TimeOffset = (long) time_offset;
  78.     }
  79.     else
  80.     {
  81.         command_error_message (BAD_ARGUMENT, more_arguments-1);
  82.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  83.     }
  84.     }
  85.     return more_arguments;
  86. }
  87.  
  88. char *set_time_segments (char *arguments)
  89. {
  90.     char *more_arguments;
  91.     ULONG time_segments;
  92.  
  93.     TimeSegments = INVALID_SET;  /* unless this succeeds */
  94.     more_arguments = set_ulong (arguments, &time_segments, FALSE, FALSE);
  95.     if (more_arguments == NullString)
  96.     {
  97.     TimeSegments = NOT_SET;
  98.     }
  99.     else
  100.     {
  101.     Time3D = TRUE;
  102.     TimeSegSize = NOT_SET;
  103.     if (time_segments > 0 && time_segments < LONG_MAX)
  104.     {
  105.         TimeSegments = (long) time_segments;
  106.     }
  107.     else
  108.     {
  109.         command_error_message (BAD_ARGUMENT, more_arguments-1);
  110.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  111.     }
  112.     }
  113.     return more_arguments;
  114. }
  115.  
  116. char *set_key (char *arguments)
  117. {
  118.     char *more_arguments;
  119.  
  120.     more_arguments = set_ulong (arguments, &Key, FALSE, FALSE);
  121.     return more_arguments;
  122. }
  123.  
  124. char *set_time_seg_size (char *arguments)
  125. {
  126.     char *more_arguments;
  127.     ULONG time_seg_size;
  128.  
  129.     TimeSegSize = INVALID_SET;  /* unless this succeeds */
  130.     more_arguments = set_ulong (arguments, &time_seg_size, FALSE, FALSE);
  131.     if (more_arguments == NullString)
  132.     {
  133.     TimeSegSize = NOT_SET;
  134.     }
  135.     else
  136.     {
  137.     Time3D = TRUE;
  138.     TimeSegments = NOT_SET;
  139.     if (time_seg_size > 0 && time_seg_size < LONG_MAX)
  140.     {
  141.         TimeSegSize = (long) time_seg_size;
  142.     }
  143.     else
  144.     {
  145.         command_error_message (BAD_ARGUMENT, more_arguments-1);
  146.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  147.     }
  148.     }
  149.     return more_arguments;
  150. }
  151.  
  152. char *set_smoothing_segments (char *arguments)
  153. {
  154.     char *more_arguments;
  155.     ULONG smoothing_segs;
  156.  
  157.     SmoothingSegments = INVALID_SMOOTHING;  /* unless this succeeds */
  158.     more_arguments = set_ulong (arguments, &smoothing_segs, TRUE, FALSE);
  159.     if (more_arguments == NullString)
  160.     {
  161.     SmoothingSegments = NO_SMOOTHING;
  162.     }
  163.     else
  164.     {
  165.     if (smoothing_segs <= LONG_MAX)
  166.     {
  167.         SmoothingSegments = (long) smoothing_segs;
  168.     }
  169.     else
  170.     {
  171.         command_error_message (BAD_ARGUMENT, more_arguments-1);
  172.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  173.     }
  174.     }
  175.     return more_arguments;
  176. }
  177.  
  178. char *set_time_3d (char *arguments)
  179. {
  180.     Time3D = TRUE;
  181.     return arguments;
  182. }
  183.  
  184. char *set_no_time_3d (char *arguments)
  185. {
  186.     Time3D = FALSE;
  187.     return arguments;
  188. }
  189.  
  190. char *set_hidden_3d (char *arguments)
  191. {
  192.     Hidden3D = TRUE;
  193.     return arguments;
  194. }
  195.  
  196. char *set_no_hidden_3d (char *arguments)
  197. {
  198.     Hidden3D = FALSE;
  199.     return arguments;
  200. }
  201.  
  202. char *set_signed (char *arguments)
  203. {
  204.     InputFormat.zero = 0;
  205.     return arguments;
  206. }
  207.  
  208. char *set_unsigned (char *arguments)
  209. {
  210.     int sample_width = (InputFormat.bits > 8) ? 16 : 8;
  211.     InputFormat.zero = ((unsigned long) 0xffffffff >> 
  212.                 (33 - sample_width)) + (unsigned long) 1;
  213. /*
  214.  * This is re-done at time of 'ok' command to be sure bits spec is final
  215.  */
  216.     return arguments;
  217. }
  218.  
  219. char *set_terminal (char *arguments)
  220. {
  221.     char *more_arguments;
  222.     char *terminal; 
  223.  
  224.     if (Terminal && Terminal != NullString)
  225.     {
  226.     gfree (Terminal);
  227.     Terminal = NULL;
  228.     }
  229.     more_arguments = get_filename (arguments, &terminal);
  230.     if (terminal == NullString || strlen (terminal) == 0)
  231.     {
  232.     Terminal = NULL;
  233.     }
  234.     else
  235.     {
  236.     Terminal = terminal;
  237.     }
  238.     return more_arguments;
  239. }
  240.  
  241.  
  242. char *set_plot_output (char *arguments)
  243. {
  244.     char *more_arguments;
  245.     char *plot_output; 
  246.  
  247.     if (PlotOutput && PlotOutput != NullString)
  248.     {
  249.     gfree (PlotOutput);
  250.     PlotOutput = NULL;
  251.     }
  252.     more_arguments = get_filename (arguments, &plot_output);
  253.     if (plot_output == NullString || strlen (plot_output) == 0)
  254.     {
  255.     PlotOutput = NULL;
  256.     }
  257.     else
  258.     {
  259.     PlotOutput = plot_output;
  260.     }
  261.     return more_arguments;
  262. }
  263.  
  264.  
  265. char *set_save_memory (char *arguments)
  266. {
  267.     SaveMemory = TRUE;
  268.     return arguments;
  269. }
  270.  
  271. char *set_no_save_memory (char *arguments)
  272. {
  273.     SaveMemory = FALSE;
  274.     return arguments;
  275. }
  276.  
  277. char *set_psdensity (char *arguments)
  278. {
  279.     PSDensity = TRUE;
  280.     return arguments;
  281. }
  282.  
  283. char *set_no_psdensity (char *arguments)
  284. {
  285.     PSDensity = FALSE;
  286.     return arguments;
  287. }
  288.  
  289. char *set_squared_smoothing (char *arguments)
  290. {
  291.     SquaredSmoothing = TRUE;
  292.     return arguments;
  293. }
  294.  
  295. char *set_no_squared_smoothing (char *arguments)
  296. {
  297.     SquaredSmoothing = FALSE;
  298.     return arguments;
  299. }
  300.  
  301. char *set_combine_plots (char *arguments)
  302. {
  303.     extern int Old_File_Count;
  304.  
  305.     if (!CombinePlots)
  306.     {
  307.     CombinePlots = TRUE;
  308.     Old_File_Count = (Old_File_Count > 0) ? 1 : 0;
  309.     }
  310.     return arguments;
  311. }
  312.  
  313. char *set_no_combine_plots (char *arguments)
  314. {
  315.     CombinePlots = FALSE;
  316.     Old_File_Count = 0;
  317.     return arguments;
  318. }
  319.  
  320. char *cut_combined_plot (char *arguments)
  321. {
  322.     if (Old_File_Count > 0) Old_File_Count--;
  323.     return arguments;
  324. }
  325.  
  326. char *set_db (char *arguments)
  327. {
  328.     Db = TRUE;
  329.     return arguments;
  330. }
  331.  
  332. char *set_header (char *arguments)
  333. {
  334.     Header = TRUE;
  335.     return arguments;
  336. }
  337.  
  338. char *set_no_header (char *arguments)
  339. {
  340.     Header = FALSE;
  341.     return arguments;
  342. }
  343.  
  344. char *set_logx (char *arguments)
  345. {
  346.     LogX = TRUE;
  347.     return arguments;
  348. }
  349.  
  350. char *set_logy (char *arguments)
  351. {
  352.     LogY = TRUE;
  353.     return arguments;
  354. }
  355.  
  356. char *set_no_logx (char *arguments)
  357. {
  358.     LogX = FALSE;
  359.     return arguments;
  360. }
  361.  
  362. char *set_no_logy (char *arguments)
  363. {
  364.     LogY = FALSE;
  365.     return arguments;
  366. }
  367.  
  368. char *set_no_db (char *arguments)
  369. {
  370.     Db = FALSE;
  371.     return arguments;
  372. }
  373.  
  374. char *set_time_overlap (char *arguments)
  375. {
  376.     char *beyond_argument;
  377.  
  378.     TimeOverlap = INVALID_SET;
  379.     beyond_argument = set_double (arguments, &TimeOverlap, FALSE, FALSE);
  380.     if (beyond_argument == NullString)
  381.     {
  382.     TimeOverlap = DEFAULT_TIME_OVERLAP;
  383.     }
  384.     else 
  385.     {
  386.     Time3D = TRUE;
  387.     TimeOffset = NOT_SET;
  388.     if (TimeOverlap >= 1.0 || TimeOverlap < 0.0)
  389.     {
  390.         TimeOverlap = INVALID_SET;
  391.         command_error_message (BAD_ARGUMENT, beyond_argument-1);
  392.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  393.     }
  394.     }
  395.     return beyond_argument;
  396. }
  397.  
  398. char *set_no_quantization (char *arguments)
  399. {
  400.     Quantization = MIN_QUANTIZATION;
  401.     return arguments;
  402. }
  403.  
  404. char *set_quantization (char *arguments)
  405. {
  406.     double quantization = 0.0;
  407.     char *beyond_argument;
  408.  
  409.     Quantization = BAD_QUANTIZATION;
  410.     beyond_argument = set_double (arguments, &quantization, FALSE, FALSE);
  411.     if (beyond_argument == NullString || quantization == 0.0)
  412.     {
  413.     Quantization = MIN_QUANTIZATION;  /* Default value if no argument */
  414.     }
  415.     else if (quantization < 0.0)
  416.     {
  417.     command_error_message (BAD_ARGUMENT, arguments);
  418.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  419.     }
  420.     else
  421.     {
  422.     Quantization = quantization;
  423.     }
  424.     return beyond_argument;
  425. }
  426.  
  427. char *set_multiply (char *arguments)
  428. {
  429.     char *beyond_argument;
  430.  
  431.     beyond_argument = set_double (arguments, &Multiply, FALSE, FALSE);
  432.     if (beyond_argument == NullString)
  433.     {
  434.     Multiply = 1.0L;  /* Default value if no argument */
  435.     }
  436.     return beyond_argument;
  437. }
  438.  
  439. char *set_no_one_shot_only (char *arguments)
  440. {
  441.     OneShotOnly = FALSE;
  442.     return arguments;
  443. }
  444.  
  445. char *set_topaz (char *arguments)
  446. {
  447.     Topaz = TRUE;
  448.     return arguments;
  449. }
  450.  
  451.  
  452. char *set_no_repeat_only (char *arguments)
  453. {
  454.     RepeatOnly = FALSE;
  455.     return arguments;
  456. }
  457.  
  458. char *set_bits (char *arguments)
  459. {
  460.     char *more_arguments;
  461.     ULONG bits;
  462.  
  463.     more_arguments = set_ulong (arguments, &bits, TRUE, FALSE);
  464.     if (more_arguments == NullString)
  465.     {
  466.     bits = DEFAULT_INPUT_BITS;
  467.     }
  468.     else if (1 > bits || bits > 16)
  469.     {
  470.     command_error_message (BAD_ARGUMENT, arguments);
  471.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  472.     }
  473.     else
  474.     {
  475.     InputFormat.bits = bits;
  476.     }
  477.     return more_arguments;
  478. }
  479.  
  480. char *set_octave (char *arguments)
  481. {
  482.     char *more_arguments;
  483.  
  484.     more_arguments = set_ulong (arguments, &Octave, FALSE, FALSE);
  485.     if (more_arguments == NullString)
  486.     {
  487.     Octave = 1L;
  488.     }
  489.     return more_arguments;
  490. }
  491.  
  492. char *set_one_shot_only (char *arguments)
  493. {
  494.     OneShotOnly = TRUE;
  495.     RepeatOnly = FALSE;
  496.     return arguments;
  497. }
  498.  
  499. char *set_repeat_only (char *arguments)
  500. {
  501.     RepeatOnly = TRUE;
  502.     OneShotOnly = FALSE;
  503.     return arguments;
  504. }
  505.  
  506. char *set_ignore_format (char *arguments)
  507. {
  508.     IgnoreFormat = TRUE;
  509.     return arguments;
  510. }
  511.  
  512. char *set_no_ignore_format (char *arguments)
  513. {
  514.     IgnoreFormat = FALSE;
  515.     return arguments;
  516. }
  517.  
  518. char *set_pink (char *arguments)
  519. {
  520.     Pink = TRUE;
  521.     return arguments;
  522. }
  523.  
  524. char *set_no_pink (char *arguments)
  525. {
  526.     Pink = FALSE;
  527.     return arguments;
  528. }
  529.  
  530. char *set_parseval (char *arguments)
  531. {
  532.     Parseval = TRUE;
  533.     return arguments;
  534. }
  535.  
  536. char *set_no_parseval (char *arguments)
  537. {
  538.     Parseval = FALSE;
  539.     return arguments;
  540. }
  541.  
  542. char *set_overlap (char *arguments)
  543. {
  544.     Overlap = TRUE;
  545.     return arguments;
  546. }
  547.  
  548. char *set_no_overlap (char *arguments)
  549. {
  550.     Overlap = FALSE;
  551.     return arguments;
  552. }
  553.  
  554. char *set_high_frequency (char *arguments)
  555. {
  556.     char *more_arguments;
  557.  
  558.     more_arguments = set_double (arguments, &HighFrequency, FALSE, FALSE);
  559.     if (more_arguments == NullString)
  560.     {
  561.         HighFrequency = HIGHEST_FREQUENCY;   /* No arg, return to default */
  562.     }
  563.     return more_arguments;
  564. }
  565.  
  566. char *set_low_frequency (char *arguments)
  567. {
  568.     char *more_arguments;
  569.  
  570.     more_arguments = set_double (arguments, &LowFrequency, FALSE, FALSE);
  571.     if (more_arguments == NullString)
  572.     {
  573.     LowFrequency = LOWEST_FREQUENCY;   /* No arg, return to default */
  574.     }
  575.     return more_arguments;
  576. }
  577.  
  578. char *set_low_y (char *arguments)
  579. {
  580.     char *more_arguments;
  581.  
  582.     more_arguments = set_double (arguments, &LowY, FALSE, FALSE);
  583.     if (more_arguments == NullString)
  584.     {
  585.     LowY = LOWEST_Y;   /* No arg, return to default */
  586.     }
  587.     return more_arguments;
  588. }
  589.  
  590. char *set_high_y (char *arguments)
  591. {
  592.     char *more_arguments;
  593.  
  594.     more_arguments = set_double (arguments, &HighY, FALSE, FALSE);
  595.     if (more_arguments == NullString)
  596.     {
  597.     HighY = HIGHEST_Y;   /* No arg, return to default */
  598.     }
  599.     return more_arguments;
  600. }
  601.  
  602. char *set_channel (char *arguments)
  603. {
  604.     char *more_arguments;
  605.  
  606.     Channel = 0L;    /* Purposely set to invalid value here */
  607.     more_arguments = set_ulong (arguments, &Channel, TRUE, FALSE);
  608.     if (more_arguments == NullString)
  609.     {
  610.     Channel = 1L;   /* Return to default if no argument */
  611.     }
  612.     if (Channel > FileChannels || Channel < 1)
  613.     {
  614.     error_message (SPEC_CHANNEL_UNAVAIL);
  615.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  616.     }
  617.     return more_arguments;
  618. }
  619.  
  620. char *set_start_byte (char *arguments)
  621. {
  622.     char *more_arguments;
  623.  
  624.     more_arguments = set_ulong (arguments, &StartByte, FALSE, FALSE);
  625.     if (more_arguments == NullString)
  626.     {
  627.     StartByte = 0;   /* Return to default if no argument */
  628.     }
  629.     return more_arguments;
  630. }
  631.  
  632. char *set_start_frame (char *arguments)
  633. {
  634.     char *more_arguments;
  635.  
  636.     more_arguments = set_ulong (arguments, &StartFrame, FALSE, FALSE);
  637.     if (more_arguments == NullString)
  638.     {
  639.     StartFrame = 0;   /* Return to default if no argument */
  640.     }
  641.     return more_arguments;
  642. }
  643.  
  644. char *set_frames (char *arguments)
  645. {
  646.     char *more_arguments;
  647.  
  648.     more_arguments = set_ulong (arguments, &Frames, FALSE, FALSE);
  649.     if (more_arguments == NullString)
  650.     {
  651.     Frames = ULONG_MAX;   /* Return to default if no argument */
  652.     }
  653.     return more_arguments;
  654. }
  655.  
  656. char *set_pad (char *arguments)
  657. {
  658.     Pad = TRUE;
  659.     return arguments;
  660. }
  661.  
  662. char *set_no_pad (char *arguments)
  663. {
  664.     Pad = FALSE;
  665.     return arguments;
  666. }
  667.  
  668. char *set_no_numerical (char *arguments)
  669. {
  670.     Numerical = FALSE;
  671.     return arguments;
  672. }
  673.  
  674. char *set_numerical (char *arguments)
  675. {
  676. #ifdef NUMERICAL_RECIPES_AVAILABLE
  677.     Numerical = TRUE;
  678. #else
  679.     error_message (NO_NUMERICAL);
  680.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  681. #endif
  682.     return arguments;
  683. }
  684.  
  685.  
  686. #define GNUPLOT 1
  687.  
  688. static char *set_plot_gnuplot (char *arguments)
  689. {
  690.     Plot = GNUPLOT_PLOT;
  691.     return arguments;
  692. }
  693.  
  694. static Name_Info_St plotter_names[] = {
  695.   {"GNUPLOT","G", set_plot_gnuplot},
  696.   {"","", default_argument},
  697. };
  698.  
  699.  
  700. char *set_plot (char *arguments)
  701. {
  702.     char *arg;
  703.  
  704.     arg = strtok (arguments, " ");
  705.     if (!arg) /* No argument present */
  706.     {
  707.     Plot = ANY_PLOT;  /* use the default plotter */
  708.     }
  709.     else
  710.     {
  711.     invoke_method (arg, plotter_names);
  712.     }
  713.     return arguments;
  714. }
  715.  
  716. char *set_no_plot (char *arguments)
  717. {
  718.     Plot = NO_PLOT;
  719.     return arguments;
  720. }
  721.  
  722.  
  723. #define ASCII 1
  724. #define BINARY 2
  725.  
  726. static char *set_output_format_binary (char *arguments)
  727. {
  728.     OutputFormat.binary = TRUE;
  729.     return arguments;
  730. }
  731.  
  732. static char *set_output_format_ascii (char *arguments)
  733. {
  734.     OutputFormat.binary = FALSE;
  735.     return arguments;
  736. }
  737.  
  738. static Name_Info_St output_format_names[] = {
  739.   {"ASCII","A", set_output_format_ascii},
  740.   {"BINARY","B", set_output_format_binary},
  741.   {"","", default_argument},
  742. };
  743.  
  744. char *set_output (char *arguments)
  745. {
  746.     char *arg;
  747.  
  748.     arg = strtok (arguments, " ");
  749.     if (!arg) /* No argument present */
  750.     {
  751.     command_error_message (MISSING_ARGUMENT, arguments);
  752.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  753.     }
  754.     invoke_method (arg, output_format_names);
  755.     return arguments;
  756. }
  757.  
  758. char *set_amplitude (char *arguments)
  759. {
  760.     Amplitude = TRUE;
  761.     Power = FALSE;
  762.     return arguments;
  763. }
  764.  
  765. char *set_power (char *arguments)
  766. {
  767.     Power = TRUE;
  768.     Amplitude = FALSE;
  769.     return arguments;
  770. }
  771.  
  772. char *set_fft (char *arguments)
  773. {
  774.     Power = FALSE;
  775.     Amplitude = FALSE;
  776.     return arguments;
  777. }
  778.  
  779. char *set_mean (char *arguments)
  780. {
  781.     Mean = TRUE;
  782.     return arguments;
  783. }
  784.  
  785. char *set_sum (char *arguments)
  786. {
  787.     Mean = FALSE;
  788.     return arguments;
  789. }
  790.  
  791. char *set_hann (char *arguments)
  792. {
  793.     WindowType = HANN_WINDOW;
  794.     return arguments;
  795. }
  796.  
  797. char *set_hamming (char *arguments)
  798. {
  799.     WindowType = HAMMING_WINDOW;
  800.     return arguments;
  801. }
  802.  
  803. char *set_parzen (char *arguments)
  804. {
  805.     WindowType = PARZEN_WINDOW;
  806.     return arguments;
  807. }
  808.  
  809. char *set_rectangle (char *arguments)
  810. {
  811.     WindowType = RECTANGLE_WINDOW;
  812.     return arguments;
  813. }
  814.  
  815. char *set_triangle (char *arguments)
  816. {
  817.     WindowType = TRIANGLE_WINDOW;
  818.     return arguments;
  819. }
  820.  
  821. char *set_blackman_harris_74db (char *arguments)
  822. {
  823.     WindowType = BLACKMAN_HARRIS_74DB_WINDOW;
  824.     return arguments;
  825. }
  826.  
  827. char *set_blackman_harris_92db (char *arguments)
  828. {
  829.     WindowType = BLACKMAN_HARRIS_92DB_WINDOW;
  830.     return arguments;
  831. }
  832.  
  833. char *set_welch (char *arguments)
  834. {
  835.     WindowType = WELCH_WINDOW;
  836.     return arguments;
  837. }
  838.  
  839. char *set_rotation_x (char *arguments)
  840. {
  841.     char *more_arguments;
  842.     double rot_x;
  843.  
  844.     RotX = INVALID_ROTATION;
  845.     more_arguments = set_double (arguments, &rot_x, FALSE, FALSE);
  846.     if (more_arguments == NullString)
  847.     {
  848.     RotX = DEF_ROT_X;
  849.     }
  850.     else if (0. <= rot_x && rot_x <= 180.)
  851.     {
  852.     RotX = rot_x;
  853.     }
  854.     else
  855.     {
  856.     command_error_message (BAD_ARGUMENT, arguments);
  857.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  858.     }
  859.     return more_arguments;
  860. }
  861.  
  862. char *set_rotation_z (char *arguments)
  863. {
  864.     char *more_arguments;
  865.     double rot_z;
  866.  
  867.     RotZ = INVALID_ROTATION;
  868.     more_arguments = set_double (arguments, &rot_z, FALSE, FALSE);
  869.     if (more_arguments == NullString)
  870.     {
  871.     RotZ = DEF_ROT_Z;
  872.     }
  873.     else if (0. <= rot_z && rot_z <= 360.)
  874.     {
  875.     RotZ = rot_z;
  876.     }
  877.     else
  878.     {
  879.     command_error_message (BAD_ARGUMENT, arguments);
  880.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  881.     }
  882.     return more_arguments;
  883. }
  884.  
  885. char *set_rate (char *arguments)
  886. {
  887.     char *more_arguments;
  888.  
  889.     Rate = INVALID_RATE;   /* Preset to <invalid> rate */
  890.     more_arguments = set_double (arguments, &Rate, TRUE, FALSE);
  891.     if (more_arguments == NullString)
  892.     {
  893.     Rate = AUTO_RATE;   /* Set to <auto/default> rate */
  894.     }
  895.     return more_arguments;
  896. }
  897.  
  898. char *set_interleave (char *arguments)
  899. {
  900.     char *end_argument;
  901.     ULONG interleave = 0;
  902.  
  903.     Interleave = INVALID_INTERLEAVE;   /* Force flagged value on error */
  904.     end_argument = set_ulong (arguments, &interleave, TRUE, TRUE);
  905.     if (interleave < 2)
  906.     {
  907.     command_error_message (BAD_ARGUMENT, end_argument-1);
  908.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  909.     }
  910.     else
  911.     {
  912.     Interleave = interleave;
  913.     }
  914.     return end_argument;
  915. }
  916.  
  917. char *set_no_interleave (char *arguments)
  918. {
  919.     Interleave = 1;
  920.     return arguments;
  921. }
  922.  
  923. char *set_bins (char *arguments)
  924. {
  925.     unsigned long bins = 1;
  926.     unsigned long okbins = 1;
  927.     char *new_arguments;
  928.  
  929.     NumberBins = INVALID_BINS;   /* Preset invalid value in case of error */
  930.     new_arguments = set_ulong (arguments, &bins, FALSE, FALSE);
  931.     if (new_arguments != NullString)
  932.     {
  933.     if (bins == 0)
  934.     {
  935.         NumberBins = 0;
  936.         return new_arguments;
  937.     }
  938.     okbins = get_pos_power_2 (bins);
  939.     if (okbins > LONG_MAX)
  940.     {
  941.         okbins = get_pos_power_2 (LONG_MAX / 2L);
  942.     }
  943.     NumberBins = (long) okbins;
  944.     if (NumberBins != bins)
  945.     {
  946.         bins_s_message ();
  947.     }
  948.     }
  949.     else
  950.     {
  951.     NumberBins = MAX_BINS;  /* Default...based on data count of file */
  952.     }
  953.     return new_arguments;
  954. }
  955.  
  956.  
  957. unsigned long get_pos_power_2 (unsigned long i)
  958. {
  959.     unsigned long j = 1;                /* minimum useful value */
  960.     unsigned long max = ULONG_MAX / 2;  /* max value we can safely handle */
  961.  
  962.     for (j = 1; j < max; j *= 2)
  963.     {
  964.     if (j >= i) break;
  965.     }
  966.     return j;
  967. }
  968.  
  969. char *set_no_calibrations (char *arguments)
  970. {
  971.     calibration_list__cancel (&CalibrationList);
  972.     CalibrationList = NULL;
  973.     return arguments;
  974. }
  975.  
  976. char *set_db_calibration (char *arguments)
  977. {
  978.     arguments = add_calibration (arguments, TRUE);
  979.     return arguments;
  980. }
  981.  
  982. char *set_calibration (char *arguments)
  983. {
  984.     arguments = add_calibration (arguments, FALSE);
  985.     return arguments;
  986. }
  987.  
  988. static char *add_calibration (char *arguments, BOOLEAN db_scale)
  989. {
  990.     char *more_arguments;
  991.     FILE *cal_file;
  992.     char *cal_name;
  993.  
  994.     more_arguments = get_filename (arguments, &cal_name);
  995.     if (cal_name == NullString)
  996.     {
  997.     command_error_message (MISSING_ARGUMENT, arguments);
  998.     RAISE_ERROR (NOTHING_SPECIAL);   /* longjmp outa here */
  999.     }
  1000.     if (!(cal_file = fopen (cal_name,"r")))
  1001.     {
  1002.     error_message (CANT_OPEN_INPUT_FILE);
  1003.     RAISE_ERROR (NOTHING_SPECIAL);   /* longjmp outa here */
  1004.     }
  1005.     calibration_list__add (&CalibrationList, cal_name, cal_file, db_scale);
  1006.     return more_arguments;
  1007. }
  1008.  
  1009.  
  1010. char *load_settings (char *arguments)
  1011. {
  1012.     char *more_arguments;
  1013.     char *filename;
  1014.     FILE *fptr;
  1015.  
  1016.     more_arguments = get_filename (arguments, &filename);
  1017.  
  1018.     if (filename == NullString)
  1019.     {
  1020.     command_error_message (MISSING_ARGUMENT, arguments);
  1021.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1022.     }
  1023.  
  1024.     if (!(fptr = fopen (filename,"r")))
  1025.     {
  1026.     error_message (CANT_OPEN_INPUT_FILE);
  1027.     RAISE_ERROR (NOTHING_SPECIAL); /* longjmp outa here! */
  1028.     }
  1029.     CATCH_ERROR
  1030.     {
  1031.     execute_file_commands (fptr);
  1032.     }
  1033.     END_CATCH_ERROR;
  1034.  
  1035.     fclose (fptr);
  1036.  
  1037.     return more_arguments;
  1038. }
  1039.  
  1040.  
  1041. char *set_read (char *arguments)
  1042. {
  1043.     char *more_arguments;
  1044.  
  1045.     if (ReadName && ReadName != NullString)
  1046.     {
  1047.     gfree (ReadName);
  1048.     ReadName = NullString;
  1049.     }
  1050.     if (ReadPtr != NULL && ReadPtr != stdin)
  1051.     {
  1052.     fclose (ReadPtr);
  1053.     }
  1054.     if (Save_Data)
  1055.     {
  1056.     gfree (Save_Data);
  1057.     Save_Data = NULL;
  1058.     }
  1059.     more_arguments = get_filename (arguments, &ReadName);
  1060.     if (ReadName == NullString)
  1061.     {
  1062.     reset_format ();
  1063.     ReadPtr = NULL;
  1064.     ReadName = NULL;
  1065.     return more_arguments;
  1066.     }
  1067.     if (strlen (ReadName) == 4 && !strcmp (ReadName,"con:"))
  1068.     {
  1069.     reset_format ();
  1070.     ReadPtr = stdin;
  1071.     return more_arguments;
  1072.     }
  1073.     if (!(ReadPtr = fopen (ReadName,"r")))
  1074.     {
  1075.     error_message (CANT_OPEN_INPUT_FILE);
  1076.     reset_format ();
  1077.     RAISE_ERROR (NOTHING_SPECIAL); /* longjmp outa here! */
  1078.     }
  1079.     else
  1080.     {
  1081.     read_format ();
  1082.     }
  1083.     return more_arguments;
  1084. }
  1085.  
  1086. char *set_append (char *arguments)
  1087. {
  1088.     char *more_arguments;
  1089.  
  1090.     Appending = FALSE;
  1091.     if (WriteName && WriteName != NullString)
  1092.     {
  1093. /*    gfree (WriteName);      aliased name!  unsafe to free!  */
  1094.     WriteName = NullString;
  1095.     }
  1096.     if (WritePtr != NULL && WritePtr != stdout)
  1097.     {
  1098.     fclose (WritePtr);
  1099.     }
  1100.     WritePtr = NULL;
  1101.     more_arguments = get_filename (arguments, &WriteName);
  1102.     if (WriteName == NullString)
  1103.     {
  1104.     Appending = TRUE;
  1105.     WriteName = NULL;
  1106.     return more_arguments;
  1107.     }
  1108.     WritePtr = fopen (WriteName,"a");
  1109.     if (!WritePtr)
  1110.     {
  1111.     error_message (CANT_CREATE_OUTPUT_FILE);
  1112.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1113.     }
  1114.     Appending = TRUE;
  1115.     return more_arguments;
  1116. }
  1117.  
  1118. char *set_write (char *arguments)
  1119. {
  1120. /*
  1121.  * The following is intended to maximize portability
  1122.  * by using (ultimately) only ANSI C functions and notions
  1123.  *
  1124.  * Note: If the first characters match the TEMP_DATAFILE_NAME, the
  1125.  *   previous version will be overwritten with impunity, otherwise:
  1126.  * if a file exists with the same name, it will be renamed to backup.
  1127.  * Only one level of backup files is created.
  1128.  * It will fail if filesystem does not allow a one character suffix.
  1129.  * If the backup fails, file is not opened for output.
  1130.  */
  1131.     char *more_arguments;
  1132.     FILE *temp_ptr;
  1133.  
  1134.     Appending = FALSE;
  1135.     if (WriteName && WriteName != NullString)
  1136.     {
  1137. /*    gfree (WriteName);      aliased name!  unsafe to free!  */
  1138.     WriteName = NullString;
  1139.     }
  1140.     if (WritePtr != NULL && WritePtr != stdout)
  1141.     {
  1142.     fclose (WritePtr);
  1143.     }
  1144.     WritePtr = NULL;
  1145.     more_arguments = get_filename (arguments, &WriteName);
  1146.     if (WriteName == NullString)
  1147.     {
  1148.     WriteName = NULL;
  1149.     return more_arguments;
  1150.     }
  1151.     if (strlen (WriteName) == 4 && !strcmp (WriteName,"con:"))
  1152.     {
  1153.     WritePtr = stdout;
  1154.     return more_arguments;
  1155.     }
  1156.     if (!is_temp_file (WriteName))
  1157.     {
  1158.     if (temp_ptr = fopen (WriteName,"r"))
  1159.     {
  1160.         int oldlen;
  1161.         char *newname;
  1162.         int old_backup_deleted = FALSE;
  1163.         
  1164.         fclose (temp_ptr);
  1165.         oldlen = strlen (WriteName);
  1166.         newname = gmalloc (oldlen + 2, NOTHING_SPECIAL);
  1167.         strcpy (newname, WriteName);
  1168.         newname[oldlen] = BACKUP_FILE_CHARACTER;
  1169.         newname[oldlen + 1] = '\0';
  1170.         if (temp_ptr = fopen (newname,"r"))
  1171.         {
  1172.         old_backup_deleted = TRUE;
  1173.         fclose (temp_ptr);
  1174.         remove (newname);
  1175.         }
  1176.         if (rename (WriteName, newname))
  1177.         {
  1178.         error_message (OUTPUT_BACKUP_FAILURE);
  1179.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1180.         }
  1181.         else if (old_backup_deleted)
  1182.         {
  1183.         error_message (BACKUP_OVERWRITTEN);  /* Warning only. */
  1184.         }
  1185.         else
  1186.         {
  1187.         error_message (BACKUP_CREATED);  /* Warning only. */
  1188.         }
  1189.         gfree (newname);
  1190.     }
  1191.     }
  1192.     WritePtr = fopen (WriteName,"w");
  1193.     if (!WritePtr)
  1194.     {
  1195.     error_message (CANT_CREATE_OUTPUT_FILE);
  1196.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1197.     }
  1198.     return more_arguments;
  1199. }
  1200.  
  1201. char *clear_plot_commands (char *arguments)
  1202. {
  1203.     PlotCommands = NULL;
  1204.     return arguments;
  1205. }
  1206.  
  1207. char *add_plot_command (char *arguments)
  1208. {
  1209.     struct list_st **plot_basep = &PlotCommands;
  1210.     char *command;
  1211.  
  1212.     while (*plot_basep != NULL)
  1213.     {
  1214.     plot_basep = &((*plot_basep)->next);
  1215.     }
  1216.     *plot_basep = (struct list_st *) gcalloc (1, sizeof (struct list_st), 
  1217.               NOTHING_SPECIAL);
  1218.     command = (char *) gmalloc (1+strlen(arguments), NOTHING_SPECIAL);
  1219.     strcpy (command, arguments);
  1220.     (*plot_basep)->node = (void *) command;
  1221.     (*plot_basep)->next = NULL;
  1222.     return NullString;
  1223. }
  1224.  
  1225. void write_plot_commands (FILE *fp, char *cstr, char *name,
  1226.               struct list_st *plot_commands)
  1227. {
  1228.     while (plot_commands)
  1229.     {
  1230.     /* fortunately, GNUPLOT ignores leading whitespace */
  1231.     fprintf (fp, "%s%s %s\n", cstr, name, 
  1232.         (char *) plot_commands->node);
  1233.     plot_commands = plot_commands->next;
  1234.     }
  1235. }
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241. /* Utility functions *****************************************************/
  1242.  
  1243. /*
  1244.  * Set an unsigned long value
  1245.  * decimal, octal, or hex accepted
  1246.  * handle error, incl. termination by other than NULL, space, or newline
  1247.  * on error, longjmp (to command loop)
  1248.  * a flag determines if value greater than 0 is required
  1249.  * a flag determines if argument is mandatory (then longjmp if not present)
  1250.  * if argument not mandatory, return NullString if no arg found, 
  1251.  *  otherwise, return string pointer to first char past end of filename
  1252.  *    (this may be simply a pointer to a '\0' byte)
  1253.  * value is only set if found and successful
  1254.  */
  1255. static char *set_ulong (char *arguments, unsigned long *valuep, 
  1256.                int gt_0_req, int arg_req)
  1257. {
  1258.     char *arg;
  1259.     char *beyondpointer = NULL;
  1260.     unsigned long newvalue;
  1261.  
  1262.     arg = strtok (arguments, " ");
  1263.     if (!arg) /* No argument present */
  1264.     {
  1265.     if (arg_req)
  1266.     {
  1267.         command_error_message (MISSING_ARGUMENT, arguments);
  1268.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1269.     }
  1270.     return NullString;
  1271.     }
  1272.     errno = 0;
  1273.     newvalue = strtoul (arg, &beyondpointer, 0);
  1274.     if (errno || (newvalue == 0 && gt_0_req))
  1275.     {
  1276.     command_error_message (BAD_ARGUMENT, arg);
  1277.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1278.     }
  1279.     if (*beyondpointer != ' ' && *beyondpointer != '\0' && 
  1280.     *beyondpointer != '\n')    /* illegal character in number */
  1281.     {
  1282.     command_error_message (BAD_ARGUMENT, beyondpointer);
  1283.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1284.     }
  1285.     *valuep = newvalue;
  1286.     return beyondpointer;
  1287. }
  1288.  
  1289. /*
  1290.  * Set a double value
  1291.  * handle error, incl. termination by other than NULL, space, or newline
  1292.  * on error, longjmp (to command loop)
  1293.  * a flag determines if value greater than 0 is required
  1294.  * a flag determines if argument is mandatory (then longjmp if not present)
  1295.  * if argument not mandatory, return NullString if no argument found
  1296.  *   otherwise, return string ptr to character following argument
  1297.  *     (this may be a string ptr to a '\0' byte)
  1298.  * value is only set if found and successful
  1299.  */
  1300. static char *set_double (char *arguments, double *valuep,
  1301.                int gt_0_req, int arg_req)
  1302. {
  1303.     char *arg;
  1304.     char *beyondpointer = NULL;
  1305.     double newvalue;
  1306.  
  1307.     arg = strtok (arguments, " ");
  1308.     if (!arg) /* No argument present */
  1309.     {
  1310.     if (arg_req)
  1311.     {
  1312.         command_error_message (MISSING_ARGUMENT, arguments);
  1313.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1314.     }
  1315.     return NullString;
  1316.     }
  1317.     errno = 0;
  1318.     newvalue = strtod (arg, &beyondpointer);
  1319.     if (errno || (newvalue  <= 0.0L && gt_0_req))
  1320.     {
  1321.     command_error_message (BAD_ARGUMENT, arg);
  1322.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1323.     }
  1324.     if (*beyondpointer != ' ' && *beyondpointer != '\0' && 
  1325.     *beyondpointer != '\n')    /* illegal character in number */
  1326.     {
  1327.     command_error_message (BAD_ARGUMENT, beyondpointer);
  1328.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1329.     }
  1330.     *valuep = newvalue;
  1331.     return beyondpointer;  /* beyondpointer points to char past arg */
  1332. }
  1333.  
  1334.  
  1335. static char* get_filename (char *arguments, char **filename_pp)
  1336. {
  1337.     char *arg;
  1338.     char *end;
  1339.     char *name;
  1340.     char old_endc;
  1341.     int len;
  1342.  
  1343.     arg = strtok (arguments, "\n");
  1344.     if (!arg)
  1345.     {
  1346.     if (CommandMode == INTERACTIVE_MODE || 
  1347.         CommandMode == WORKBENCH_MODE)
  1348.     {
  1349.         *filename_pp = NullString;  /* Default to stdin or stdout */
  1350.         return NullString;
  1351.     }
  1352.     else
  1353.     {
  1354.         command_error_message (MISSING_ARGUMENT, arguments);
  1355.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1356.     }
  1357.     }
  1358.     if (*arg == '\"' || *arg == '\'')  /* filename in quotes */
  1359.     {
  1360.     end = arg + 1;
  1361.     while (*end != '\0' && *end != *arg && *end != '\n')
  1362.     {
  1363.         end++;
  1364.     }
  1365.     if (*end != *arg)
  1366.     {
  1367.         command_error_message (BAD_NAME, end);
  1368.         RAISE_ERROR (NOTHING_SPECIAL);
  1369.     }
  1370.     arg++;         /* Pass initial quote */
  1371.     }
  1372.     else
  1373.     {
  1374.     end = arg;
  1375.     while (*end != '\0' && *end != ' ' && *end != '\n')
  1376.     {
  1377.         end++;
  1378.     }
  1379.     }
  1380.     old_endc = *end;    /* save original termination */
  1381.     *end = '\0';        /* terminate name string */
  1382.     len = strlen (arg);
  1383.     name = gmalloc (len + 1, NOTHING_SPECIAL);    /* Leave room for null! */
  1384.     strcpy (name,arg);
  1385.     *filename_pp = name;
  1386.     if (old_endc != '\0')
  1387.     {
  1388.     *end++ = old_endc;  /* restore original term, then skip it */
  1389.     }
  1390.     return end;
  1391. }
  1392.  
  1393. BOOLEAN is_temp_file (char *filename)
  1394. {
  1395.     char *template = TEMP_NAME_PREFIX;
  1396.     char fchar, tchar;
  1397.  
  1398.     if (!filename || filename == NullString)
  1399.     {
  1400.     return FALSE;
  1401.     }
  1402.  
  1403.     while (tchar = *template++)
  1404.     {
  1405.     if (!(fchar = *filename++)) return FALSE;
  1406.     if (fchar != tchar) return FALSE;
  1407.     }
  1408.     return TRUE;
  1409. }
  1410.  
  1411. ULONG magic_number (char *string)
  1412. {
  1413.     ULONG magic = 0;
  1414.  
  1415.     for (;*string;magic+=*string,string++);
  1416.     return magic;
  1417. }
  1418.  
  1419. char *save_settings (char *arguments)
  1420. {
  1421.     return save_settings_or_parameters (arguments, FALSE);
  1422. }
  1423.  
  1424.  
  1425. char *save_parameters (char *arguments)
  1426. {
  1427.     return save_settings_or_parameters (arguments, TRUE);
  1428. }
  1429.  
  1430. char *save_settings_or_parameters 
  1431.   (char *arguments, BOOLEAN parameters_only)
  1432. {
  1433. /*
  1434.  * This follows much of the same logic as is used for opening a spectrum
  1435.  *
  1436.  * If a file exists with the same name, it will be renamed to backup.
  1437.  * Only one level of backup files is created.
  1438.  * It will fail if filesystem does not allow a one character suffix.
  1439.  * If the backup fails, file is not opened for output.
  1440.  */
  1441.     char *more_arguments;
  1442.     FILE *temp_ptr = NULL;
  1443.     FILE *savefile_ptr = NULL;
  1444.     char *savefile_name;
  1445.  
  1446.     more_arguments = get_filename (arguments, &savefile_name);
  1447.     if (savefile_name == NullString)
  1448.     {
  1449.     command_error_message (MISSING_ARGUMENT, arguments);
  1450.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1451.     }
  1452.     if (temp_ptr = fopen (savefile_name, "r"))
  1453.     {
  1454.     int oldlen;
  1455.     char *newname;
  1456.     int old_backup_deleted = FALSE;
  1457.         
  1458.     fclose (temp_ptr);
  1459.     oldlen = strlen (savefile_name);
  1460.     newname = gmalloc (oldlen + 2, NOTHING_SPECIAL);
  1461.     strcpy (newname, savefile_name);
  1462.     newname[oldlen] = BACKUP_FILE_CHARACTER;
  1463.     newname[oldlen + 1] = '\0';
  1464.     if (temp_ptr = fopen (newname,"r"))
  1465.     {
  1466.         old_backup_deleted = TRUE;
  1467.         fclose (temp_ptr);
  1468.         remove (newname);
  1469.     }
  1470.     if (rename (savefile_name, newname))
  1471.     {
  1472.         error_message (OUTPUT_BACKUP_FAILURE);
  1473.         RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1474.     }
  1475.     else if (old_backup_deleted)
  1476.     {
  1477.         error_message (BACKUP_OVERWRITTEN);  /* Warning only. */
  1478.     }
  1479.     else
  1480.     {
  1481.         error_message (BACKUP_CREATED);  /* Warning only. */
  1482.     }
  1483.     gfree (newname);
  1484.     }
  1485.     savefile_ptr = fopen (savefile_name,"w");
  1486.     if (!savefile_ptr)
  1487.     {
  1488.     error_message (CANT_CREATE_OUTPUT_FILE);
  1489.     RAISE_ERROR (NOTHING_SPECIAL);  /* longjmp outa here! */
  1490.     }
  1491.     write_settings (savefile_ptr, NullString, parameters_only, 
  1492.             parameters_only);
  1493.     fclose (savefile_ptr);
  1494.     return more_arguments;
  1495. }
  1496.  
  1497.